package gropack;

public class ExprPrinter implements Visitor {
	String s;
	
	public ExprPrinter(){
		s = new String();
	}
	
	public void visitIntExpr(IntExpr e){
		s += e.getValeur();
	}
	
	@Override
	public void visitFloatExpr(FloatExpr e) {
		s += e.getValeur();
	}
	
	public void visitPlusExpr(PlusExpr e){
		s += "(";
		(e.getLeft()).accept(this);
		s += "+";
		(e.getRight()).accept(this);
		s += ")";
	}
	
	public void visitMoinsExpr(MoinsExpr e){
		s += "(";
		(e.getLeft()).accept(this);
		s += "-";
		(e.getRight()).accept(this);
		s += ")";
	}
	
	public void visitDivExpr(DivExpr e){
		s += "(";
		(e.getLeft()).accept(this);
		s += "/";
		(e.getRight()).accept(this);
		s += ")";
	}
	
	public void visitMultExpr(MultExpr e){
		s += "(";
		(e.getLeft()).accept(this);
		s += "*";
		(e.getRight()).accept(this);
		s += ")";
	}
	
	public void visitExpr(Expr e){}
	
	public String result(){
		return s;
	}

}